; sample program 3
; gives a short overview about function calls

START
LDN stk,R31	; initialize stack
LDN var,R1	; initialize variable var
JSR subr	; jump tu subroutine subr
LOAD R1,R2
IN 1,R3
ADD R2,R3,R2
STOR R2,R1	; write value back to program memory
JSR subr
HALT

subr: LDN var,R15	; initialize var for subroutine
      LOAD R15,R16	; get value of var
      OUT R16,2
      RET		; return to main routine

var: DC 100	; set variable var
stk: DS 10	; set stack to size stk
